package org.bookie.model;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.validator.NotNull;

/**
 * Class modelling a Transaction of {@link User}s account.
 * 
 * @author drobiazko
 * 
 */
@Entity
@Table(name="Transactions")
public class Transaction extends CommonEntity {
	private static final long serialVersionUID = 1L;

	@ManyToOne
	@JoinColumn(name = "USER_ID", nullable = false)
	private User user;

	@Basic @NotNull private Date date;

	@Basic @NotNull private Double amount;

	@ManyToOne
	@JoinColumn(name = "BETSLIP_ID", nullable = true)
	private BetSlip betSlip;

	@Enumerated(EnumType.STRING) @NotNull
	private Comment comment;

	protected Transaction() {
		super();
	}

	public Transaction(User user, Double amount, Comment comment, BetSlip betSlip) {
		this.user = user;
		this.amount = amount;
		this.comment = comment;
		this.date = new Date();
		this.betSlip = betSlip;

	}

	public Double getAmount() {
		return amount;
	}

	public BetSlip getBetSlip() {
		return betSlip;
	}

	public Comment getComment() {
		return comment;
	}

	public Date getDate() {
		return date;
	}

	public User getUser() {
		return user;
	}

}
